<?php

namespace app\admin\model;

use think\Model;
use think\Db;
class Recharge extends Model
{
    // 表名
    protected $name = 'User_echarge';
    public function user($list){
        $count=0;
        $recharge=0;
        foreach ($list as $key=>&$li){
            $users=DB::table('cy_users')->where('user_id='.$li['user_id'])->field('user_id,user_name,full_name')->find();
            $list[$key]['user_name']=$users['user_name'];
            $list[$key]['full_name']=$users['full_name'];
            $count=DB::table('cy_user_echarge')->where('user_id='.$li['user_id'].' and process_type=0 and is_paid=1')->count();
            $list[$key]['count']=$count;
            $recharge=DB::table('cy_user_echarge')->where('user_id='.$li['user_id'].' and process_type=0 and is_paid=1')->sum('amount');
            $list[$key]['amounts']=$recharge;
        }
        return $list;
    }

    public function lists($list){
        $count=0;
        $recharge=0;
        foreach ($list as $key=>&$li){
            $users=DB::table('cy_users')->where('user_id='.$li['user_id'])->field('user_id,user_name,full_name')->find();
            $list[$key]['user_name']=$users['user_name'];
            $list[$key]['full_name']=$users['full_name'];
            $count=DB::table('cy_user_echarge')->where('user_id='.$li['user_id'].' and process_type=1')->count();
            $list[$key]['count']=$count;
            $recharge=DB::table('cy_user_echarge')->where('user_id='.$li['user_id'].' and process_type=1')->sum('amount');
            $list[$key]['amounts']=$recharge;
        }
        return $list;
    }








}